package cn.gpnu.web.servlet;

import cn.gpnu.dao.Userdao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/add_servlet")
public class add_servlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置编码
        resp.setContentType("text/html;charset=utf-8");
        //输出
//        int id = req.getIntHeader("id");
        int id = Integer.parseInt(req.getParameter("id"));
        int gold = Integer.parseInt(req.getParameter("gold"));

        Userdao dao = new Userdao();
//        System.out.println(id);
        dao.add_gold(id,gold);
//        System.out.println(flag);
        dao.add_time(id,gold);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }
}
